package com.pattern.strategy.comparable;

public class Cat implements MyComparable {

    int weight, height;

    public Cat(int weight, int height) {
        this.weight = weight;
        this.height = height;
    }

    /**
     * 不使用泛型，这里需要强制类型转换
     * @param c
     * @return
     */
    public int compareTo(Object c) {
        Cat cat = (Cat) c; // 问题： 这里存在强制类型转换
        if (this.weight < cat.weight) return -1;
        else if (this.weight > cat.weight) return 1;
        else return 0;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "weight=" + weight +
                ", height=" + height +
                '}';
    }

}
